<template>
  <ul class="themeNav">
    <li
      v-for="(type, idx) in types"
      :key="idx"
      @click="changeIdx(idx)"
      :class="{ colorBlue: typeIdx === idx }"
    >
      {{ type }}
      <div></div>
    </li>
  </ul>
</template>

<script lang="ts" setup>
import { parseInt } from 'lodash'
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const types = ['综合', '数理', '语言', '开发', '算法', '其他']
let idx = 0

const route = useRoute(),
  router = useRouter()
let typeIdx = computed(() => {
  return parseInt(route.query.t as string) || 0
})

function changeIdx(idx: number) {
  router.push({
    path: route.path,
    query: {
      ...route.query,
      t: idx,
    },
  })
}
</script>

<style scoped lang="scss">
@import 'style/config';
@import 'style/shortcut';

.themeNav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: $themeNavWidth;
  height: $themeNavHeight;
  background-color: white;

  li {
    position: relative;
    flex-grow: 1;
    padding: 0 20px;
    font-size: 17px;
    line-height: $themeNavHeight;
    text-align: center;

    &:hover {
      color: $blue;
      cursor: pointer;

      div {
        width: 40%;
      }
    }

    div {
      position: absolute;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 0;
      height: 4px;
      background-color: $darkBlue;
      transition: 0.2s;
    }
  }
}
</style>
